﻿using DevExpress.XtraGrid.Demos.util;
using Luna小店.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Luna小店.UC
{
    public partial class Frm登陆窗口 : DevExpress.XtraEditors.XtraForm
    {
        public static StoreAssitantDTO storeAssitantDTO = new StoreAssitantDTO();
        public Frm登陆窗口()
        {
            InitializeComponent();
        }

        private void simpleButton确定_Click(object sender, EventArgs e)
        {
            this.用户名密码校验();
        }

        private void simpleButton忘记_Click(object sender, EventArgs e)
        {
            new Frm重置密码().ShowDialog();
        }

        private void textBox密码_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                this.用户名密码校验();
            }
        }

        private void 用户名密码校验()
        {
            storeAssitantDTO = FunctionHelper.JsonDeserialization<StoreAssitantDTO>(RestCall.httpGetMethod(URL.接口url + "/store/checkPassword?code=" + this.textBox用户名.Text.Trim() + "&password=" + this.textBox密码.Text.Trim()));
            if (storeAssitantDTO.checkPass)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名密码错误请重新输入!");
            }
        }
    }
    /// <summary>
    /// 登陆校验返回
    /// </summary>
    public class StoreAssitantDTO
    {
        public Boolean checkPass { get; set; }//是否验证通过
        public String id { get; set; }//id
        public String code { get; set; }//编码
        public String name { get; set; }//名称
        public String shopId { get; set; }//店铺id
        public StoreAssitantDTO()
        {
            this.checkPass = false;
        }
    }
}
